
import threading
import time

task_act_items = []


def task_fn(task_ack):
    while task_ack["enabled"]:
        print("-----------------", task_ack["count"])
        time.sleep(5)
        task_ack["count"] = task_ack["count"] + 1


def start_task_thread():
    for cur_task_thread in task_act_items:
        cur_task_thread["enabled"] = False
    cur_thread_task = {
        "count": 1,
        "enabled": True
    }
    task_act_items.append(cur_thread_task)
    threading.Thread(target=task_fn, args=(cur_thread_task,)).start()



if __name__ == '__main__':
    count = 0
    while True:
        if count < 5:
            start_task_thread()

        count = count + 1
        time.sleep(2)



